package com.lam.common.context;

import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author lam
 *
 */
@Component
public class AppContext implements BeanFactoryPostProcessor, ApplicationContextAware{
	
	/** Spring应用上下文环境 */
	private ApplicationContext applicationContext;
	private ConfigurableListableBeanFactory beanFactory;
	
	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
		this.beanFactory = beanFactory;
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) {
		this.applicationContext = applicationContext;
		ContextHolder.setApplicationContext(this);
	}
	
	public ApplicationContext getApplicationContext() {
		return this.applicationContext;
	}

	public ConfigurableListableBeanFactory getBeanFactory() {
		return beanFactory;
	}

	public void setBeanFactory(ConfigurableListableBeanFactory beanFactory) {
		this.beanFactory = beanFactory;
	}

}
